package gameSocketer.socketParsers
{
	import com.adobe.serialization.json.JSON;
	
	import gameSocketer.socketSenders.LoginSocketSender;
	
	import gameUi.Event.LoginEvent;
	
	public class LoginSocketPaser extends SocketParserBase
	{
		public function LoginSocketPaser()
		{
			super();
		}
		override public function parseData(lengh:int=0):void{
			switch(launch.readByte()){
				case 0:
					tempObj =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2));
					var md5Key:String=tempObj.key;
					trace("md5Key==",md5Key);
					LoginSocketSender.getInstance().passwordEncryptPack(md5Key);
					break;
				case 1:
					trace("lengh",lengh);
					tempObj =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2));
					
					BlackJack.role.roleId = tempObj.role_id;
					var result:int = tempObj.result;
					
					switch(result){
						case 1://成功
							BlackJack.eventTower.dispatchEvent(new LoginEvent(LoginEvent.LOGIN_SUCCESS));
							break;
						case 2://用户名密码错误
							BlackJack.loginUI.tipStr("用户名密码错误");
							break;
						case 3://服务器繁忙
							BlackJack.loginUI.tipStr("服务器繁忙");
							break;
						case 4://账户冻结
							BlackJack.loginUI.tipStr("账户冻结");
							break;
						case 5://账号在线中
							BlackJack.loginUI.tipStr("账号在线中");
							break;
						case 6://未知错误
							BlackJack.loginUI.tipStr("未知错误");
							break;
					}
					break;
				case 2:
					tempObj =com.adobe.serialization.json.JSON.decode(launch.readUTFBytes(lengh-2));
					BlackJack._gameUi.roleMoney =  tempObj.role_Integration.toString();//账户余额
					BlackJack._gameUi.tittle.txtMoney.text = tempObj.role_Balance.toString();//筹码余额
					break;
			}
		}
	}
}